Skip to content

fix(scancode): handle Click 8.3+ UNSET in plugin options to avoid Sentinel errors#259

Merged
soimkim merged 1 commit intomainfrom
click
Mar 19, 2026
Merged

fix(scancode): handle Click 8.3+ UNSET in plugin options to avoid Sentinel errors#259
soimkim merged 1 commit intomainfrom
click

Conversation

@soimkim
Copy link
Contributor

@soimkim soimkim commented Mar 18, 2026

Description

  • Bug Fixes
    • Enhanced Scancode analysis stability by resolving compatibility issues with parameter handling in recent library versions.

@soimkim soimkim self-assigned this Mar 18, 2026
@soimkim soimkim added the bug fix [PR] Fix the bug label Mar 18, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2026

📝 Walkthrough

Walkthrough

Introduces a workaround for Click UNSET defaults in Scancode's CLI by detecting and replacing UNSET values with appropriate fallbacks (empty tuple for multi-values, False for booleans, None for others) before executing the scan using a new helper function with guarded exception handling.

Changes

Cohort / File(s) Summary
Scancode CLI UNSET Workaround
src/fosslight_source/run_scancode.py
Adds workaround for Click UNSET defaults by detecting and replacing UNSET values with appropriate fallbacks. Introduces conditional UNSET import (for Click >= 8.3 compatibility) and new _apply_scancode_unset_workaround() helper function. Refactors cli.run_scan invocation to use kwargs dictionary with guarded exception handling around the workaround application.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: handling Click 8.3+ UNSET values in scancode plugin options to prevent Sentinel errors, which aligns with the workaround implementation.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch click
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use your project's `ruff` configuration to improve the quality of Python code reviews.

Add a Ruff configuration file to your project to customize how CodeRabbit runs ruff.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/fosslight_source/run_scancode.py (1)

55-56: Keep traceback in debug logs for skipped workaround path.

Catching here is reasonable, but the current log drops stack context, which makes production triage harder.

🔧 Suggested tweak
-    except Exception as ex:  # pragma: no cover
-        logger.debug("scancode UNSET workaround skipped: %s", ex)
+    except Exception as ex:  # pragma: no cover
+        logger.debug("scancode UNSET workaround skipped: %s", ex, exc_info=True)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fosslight_source/run_scancode.py` around lines 55 - 56, The current
except block catches Exception as ex in run_scancode.py but logs only the
exception message, losing stack context; update the except Exception as ex
handler (the block around the logger.debug call) to include the traceback in the
debug log by passing exc_info=True to logger.debug (keeping the existing message
and the ex variable) so the full stack trace is preserved in logs for production
triage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/fosslight_source/run_scancode.py`:
- Around line 55-56: The current except block catches Exception as ex in
run_scancode.py but logs only the exception message, losing stack context;
update the except Exception as ex handler (the block around the logger.debug
call) to include the traceback in the debug log by passing exc_info=True to
logger.debug (keeping the existing message and the ex variable) so the full
stack trace is preserved in logs for production triage.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 060fd778-31c8-4cae-81b3-a5ef5ab3c9c9

📥 Commits

Reviewing files that changed from the base of the PR and between 69ccd22 and c4afeb8.

📒 Files selected for processing (1)
  • src/fosslight_source/run_scancode.py

@soimkim soimkim merged commit 41242b4 into main Mar 19, 2026
7 checks passed
@soimkim soimkim deleted the click branch March 19, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix [PR] Fix the bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant